package cn.xianshu.pay.domain;

import cn.xianshu.basic.domain.BasicDomain;
import com.alipay.easysdk.kernel.Config;
import lombok.Data;

@Data
public class PayAlipayInfo extends BasicDomain {
        /**
         * 店铺ID
         */
        private String shop_id;
        /**
         * 店铺名字
         */
        private String shopName;
        /**
         * 支付宝的APPid
         */
        private String appid;
        /**
         * 应用私钥
         */
        private String merchant_private_key;
        /**
         * 支付宝公钥
         */
        private String alipay_public_key;
        /**
         * 协议
         */
        private String protocol;
        /**
         * 支付宝网关
         */
        private String gatewayHost;
        /**
         * 签名类型
         */
        private String signType;
        /**
         * 异步回调地址  内网穿刺
         */
        private String notifyUrl;
        /**
         * 同步回调地址
         */
        private String returnUrl;


        /**
         * 创建支付宝的配置对象
         * @return
         */
        public Config getOptions() {
                Config config = new Config();
                config.protocol = this.protocol;
                config.gatewayHost = this.gatewayHost;
                config.signType = this.signType;
                config.appId = this.appid;
                // 为避免私钥随源码泄露，推荐从文件中读取私钥字符串而不是写入源码中
                config.merchantPrivateKey = this.merchant_private_key;
                //可设置异步通知接收服务地址（可选）
                config.notifyUrl = this.notifyUrl;
                config.alipayPublicKey =this.alipay_public_key;
                return config;
        }
}
